<?php 
$images = isset($images)?$images:array();
$limit = isset($limit)?$limit:999;
$picType = isset($picType)?$picType:0;
?>
<div id="imgShow">
<?php if(!empty($images)):?>
<?php foreach($images as $img):?>
	<div class="listone">
	<?php if($picType==service_type::PHOTO):?>
		<img src="<?php echo $img['src'];?>"/>
		<input type="hidden" name="img[]" value="<?php echo $img['src'];?>" />
	<?php else:?>
		<img src="<?php echo $img['src'];?>" width="100" height="100" />
	<?php endif;?>
	<span><a id="<?php echo $img['id'];?>" href="javascript:void(0);" class="itemDel">删除</a></span></div>
<?php endforeach;?>
<?php endif;?>
</div>
<input type="file" name="file_upload" id="file_upload" />
<!--<a href="javascript:$('#file_upload').uploadify('upload','*')">Upload Files</a>-->
<script type="text/javascript">
$(document).ready(function(){
	var showThumb = "<?php echo $picType;?>";
	$(".itemDel").click(function(){
		if(confirm("确认删除")){
			that = $(this);
			$.post("<?php echo url('image/del');?>",{id:that.attr('id')},function(data){
				if(data.s==1){
					that.parent().parent().remove();
				}else{
					alert(data.i);
				}
			});
		}
		return false;
	});
	$("#file_upload").uploadify({
		'swf' : "<?php echo public_path('images/admin/uploadify/uploadify.swf');?>",
		'uploader':"<?php echo url('image/upload');?>",
		'formData':{'picType':"<?php echo $picType;?>"},
		'removeTimeout':'10',
		//'auto' :false,
		'uploadLimit':"<?php echo $limit;?>",
		'buttonImage':'<?php echo public_path('images/admin/down.jpg');?>',
		'onUploadSuccess':function(file,data,response){
			if(showThumb=='<?php echo service_type::PHOTO;?>'){
				var str = "<div class='listone'><img src='"+data+"' id='target' />";
				str = str+"<input type='hidden' name='img[]' value='"+data+"' />";
				str = str+"<input type='hidden' id='x' name='pic[x]' />";
				str = str+"<input type='hidden' id='y' name='pic[y]' /></div>";
				str = str+"<script type='text/javascript'>function showCoords(c){$('#x').val(c.x);$('#y').val(c.y);}";
				str = str+"jQuery(function($){var jcrop_api, boundx, boundy;$('#target').Jcrop({onChange: showCoords,onSelect: showCoords,";
				str = str+"aspectRatio: 1},function(){jcrop_api = this;jcrop_api.animateTo([100,100,371,371]);";
				str = str+"jcrop_api.setOptions({minSize:[271,271]});});});<\/script>";
				$("#imgShow").html(str);
			}else{
				var str = "<div class=\"listone\"><img src='"+data+"' width='100' height='100' />";
				str = str+"<input type='hidden' name='img[]' value='"+data+"' /></div>";
				$("#imgShow").append(str);
			}
		},
	});		
});

</script>
